package cn.czxy.share.domain;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;

/**
 * @author shenghan
 * @version 1.0
 * @date 2019/4/13 0013
 * 共享文件类  用于将JSP传入的参数封装为一个包含共享模块所需信息的ShareFile对象,
 * 此对象贯穿整个共享模块  为共享模块的核心JavaBean
 * 此对象封装的所有属性 可以为整个模块及项目提供必需参数和实例化对象
 */
public class ShareFile{
    /**
     * 文件分享address,用于创建私密链接
     */
    private String address;
    /**
     * 来源者的登录名
     */
    private String userLoginName;
    /**
     * 此文件被共享的日期
     */
    private long shareDate;
    /**
     * 共享文件的存活时间
     */
    private long liveTime;
    /**
     * 此共享文件的文件名
     */
    private String fileName;
    /**
     * 编码后的文件路径 用于jsp请求

     */
    private String en_filePath;
    /**
     * 文件绝对路径
     */
    private String filePath;

    public String getEn_filePath() {
        return en_filePath;
    }

    public void setEn_filePath(String en_filePath) {
        this.en_filePath = en_filePath;
    }



    @Override
    public String toString() {
        return "ShareFile{" +
                "address='" + address + '\'' +
                ", userLoginName='" + userLoginName + '\'' +
                ", shareDate=" + shareDate +
                ", liveTime=" + liveTime +
                ", fileName='" + fileName + '\'' +
                ", filePath='" + filePath + '\'' +
                '}';
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getUserLoginName() {
        return userLoginName;
    }

    public void setUserLoginName(String userLoginName) {
        this.userLoginName = userLoginName;
    }

    public long getShareDate() {
        return shareDate;
    }

    public void setShareDate(long shareDate) {
        this.shareDate = shareDate;
    }

    public long getLiveTime() {
        return liveTime;
    }

    public void setLiveTime(long liveTime) {
        this.liveTime = liveTime;
    }

    public String getFileName() {
        return fileName;
    }

    public void setFileName(String fileName) {
        this.fileName = fileName;

    }

    public String getFilePath() {
        return filePath;
    }

    public void setFilePath(String filePath) {
        this.filePath = filePath;
        try {
            this.en_filePath = URLEncoder.encode(this.filePath,"utf-8");
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
    }

    public ShareFile() {

    }

    public ShareFile(String userLoginName, long shareDate, long liveTime, String fileName, String filePath) {

        this.address = "";
        this.userLoginName = userLoginName;
        this.shareDate = shareDate;
        this.liveTime = liveTime;
        this.fileName = fileName;
        this.filePath = filePath;

        try {
            this.en_filePath = URLEncoder.encode(this.filePath,"utf-8");
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
    }
}
